#!/bin/bash 

args=(
	
  # 必须使用e1000 网卡，不然网络能ping通，但是VRM无法添加CNA
  # 并且第一个网口必须得是管理网口  
  -device e1000,netdev=net0,mac=aa:51:00:00:01:00 \
  -netdev tap,id=net0,ifname=cna1_manage,script="./add_to_manage_bridge.sh" \
  -device e1000,netdev=net1,mac=aa:51:00:00:01:01 \
  -netdev tap,id=net1,ifname=cna1_storage,script="./add_to_business_bridge.sh" \

  -device e1000,netdev=net2,mac=aa:51:00:00:01:02 \
  -netdev tap,id=net2,ifname=cna1_2,script=no \

  -device e1000,netdev=net3,mac=aa:51:00:00:01:03 \
  -netdev tap,id=net3,ifname=cna1_3,script=no \
  -device e1000,netdev=net4,mac=aa:51:00:00:01:04 \
  -netdev tap,id=net4,ifname=cna1_4,script=no 

  -device e1000,netdev=n1 \
  -netdev user,id=n1,hostfwd=tcp::4222-:22,hostfwd=tcp::18888-:80,hostfwd=tcp::8443-:443 \
)
qemu-system-x86_64 \
  -enable-kvm \
  -cpu host \
  -smp 2 \
  -m 8G \
  -machine q35,accel=kvm \
  -drive file=./firmware_cna/cna.qcow2,if=virtio \
  -vnc 0.0.0.0:30,password=off \
  -daemonize \
  -cdrom ./FusionCompute_CNA-8.0.0-X86_64.iso \
  -smbios "type=1,manufacturer=HP,product=ProLiant DL380 G7,serial=CNG12345,uuid=11111111-2222-3333-4444-555555555555" \
  ${args[@]}
